#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 1.1e4 + 5;

int n, m;
string s[155];
int ans[155];
int tr[N][26], ed[N], fail[N], deg[N], cnt[N], tot;
int newnode() {
  ++tot;
  rep(i, 0, 25) tr[tot][i] = 0;
  ed[tot] = 0;
  fail[tot] = 0;
  deg[tot] = 0;
  cnt[tot] = 0;
  return tot;
}
void init() {
  tot = -1;
  newnode();
  rep(i, 1, n) ans[i] = 0;
}
void insert(string s, int i) {
  int p = 0;
  for (char c : s) {
    int ch = c - 'a';
    if (!tr[p][ch]) tr[p][ch] = newnode();
    p = tr[p][ch];
  }
  ed[p] = i;
}
void build_ac() {
  queue<int> q;
  rep(i, 0, 25) if (tr[0][i]) q.push(tr[0][i]);
  while (q.size()) {
    int p = q.front();
    q.pop();
    rep(i, 0, 25) {
      if (tr[p][i]) {
        q.push(tr[p][i]);
        int fp = tr[fail[p]][i];
        deg[fp]++;
        fail[tr[p][i]] = fp;
      } else {
        tr[p][i] = tr[fail[p]][i];
      }
    }
  }
}
void search(string& t) {
  int p = 0;
  for (char c : t) {
    p = tr[p][c - 'a'];
    cnt[p]++;
  }
}
int solve() {
  cin >> n;
  if (!n) return 0;
  init();
  rep(i, 1, n) {
    cin >> s[i];
    insert(s[i], i);
  }
  build_ac();
  string t;
  cin >> t;
  search(t);
  queue<int> q;
  rep(i, 1, tot) {
    if (!deg[i]) q.push(i);
  }
  while (q.size()) {
    int p = q.front();
    q.pop();
    if (ed[p]) ans[ed[p]] = cnt[p];
    cnt[fail[p]] += cnt[p];
    if (--deg[fail[p]] == 0) q.push(fail[p]);
  }
  int mx = 1;
  vector<string> res;
  rep(i, 1, n) {
    if (ans[i] > mx) {
      mx = ans[i];
      res.clear();
      res.push_back(s[i]);
    } else if (ans[i] == mx)
      res.push_back(s[i]);
  }
  cout << mx << endl;
  for (string x : res) cout << x << endl;
  return n;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  while (solve());
  return 0;
}